package com.ecfront.dao.impl;

import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.ecfront.dao.GoodsSortDAO;
import com.ecfront.pojo.GoodsSort;


/**
 * @version 1.0
 * @author www.ecfrom.com
 */

public class GoodsSortDAOImpl extends HibernateDaoSupport implements GoodsSortDAO {

	protected void initDao() {}


	public void save(GoodsSort transientInstance) {
		getHibernateTemplate().saveOrUpdate(transientInstance);
	}

	public void delete(GoodsSort persistentInstance) {
		getHibernateTemplate().delete(persistentInstance);
	}

	public GoodsSort findById(java.lang.Integer id) {
		GoodsSort instance = (GoodsSort) getHibernateTemplate().get(
					"com.ecfront.pojo.GoodsSort", id);
		return instance;
	}

	public List findByProperty(String propertyName, Object value) {
		String queryString = "from GoodsSort as model where model."
					+ propertyName + "= ?";
		return getHibernateTemplate().find(queryString, value);
	}


	public List findByGooGsid(Object gooGsid) {
		return findByProperty(GOOD_ID, gooGsid);
	}


	public List findByGsName(Object gsName) {
		return findByProperty(NAME, gsName);
	}


	public List findAll() {
		String queryString = "from GoodsSort";
		return getHibernateTemplate().find(queryString);
	}

	public static GoodsSortDAO getFromApplicationContext(ApplicationContext ctx) {
		return (GoodsSortDAO) ctx.getBean("GoodsSortDAO");
	}
}